﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class SupplierDetailW
    {
        int supplierDetailID;
        string supplierID;
        string itemCode;
        decimal price;
        int rank;

        [DataMember]
        public int SupplierDetailID
        {
            get { return supplierDetailID; }
            set { supplierDetailID = value; }
        }

        [DataMember]
        public string SupplierID
        {
            get { return supplierID; }
            set { supplierID = value; }
        }

        [DataMember]
        public string ItemCode
        {
            get { return itemCode; }
            set { itemCode = value; }
        }

        [DataMember]
        public decimal Price
        {
            get { return price; }
            set { price = value; }
        }

        [DataMember]
        public int Rank
        {
            get { return rank; }
            set { rank = value; }
        }

        public static SupplierDetailW convert(SupplierDetail supplierDetail)
        {
            SupplierDetailW u = new SupplierDetailW();

            u.SupplierDetailID = supplierDetail.SupplierDetailID;
            u.SupplierID = supplierDetail.SupplierID;
            u.ItemCode = supplierDetail.ItemCode;
            u.Price = supplierDetail.Price.GetValueOrDefault();
            u.Rank = supplierDetail.Rank.GetValueOrDefault();

            return u;
        }

        public static List<SupplierDetailW> convertList(List<SupplierDetail> list)
        {
            List<SupplierDetailW> listW = new List<SupplierDetailW>();

            foreach (SupplierDetail x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }
    }
}